<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">

    <ui:composition>

        <p:dialog id="MessageEditDlg" widgetVar="MessageEditDialog" modal="true" resizable="false" appendToBody="true" header="#{bundle.EditMessageTitle}">

            <h:form id="MessageEditForm">

                <h:panelGroup id="display">
                    <p:panelGrid  columns="2" rendered="#{messageController.selected != null}">

                        <h:outputLabel value="#{bundle.EditMessageLabel_idMessage}" for="idMessage" />
                        <h:outputText id="idMessage" value="#{messageController.selected.idMessage}" />

                        <p:outputLabel value="#{bundle.EditMessageLabel_tittle}" for="tittle" />
                        <p:inputText id="tittle" value="#{messageController.selected.tittle}" title="#{bundle.EditMessageTitle_tittle}" />

                        <p:outputLabel value="#{bundle.EditMessageLabel_body}" for="body" />
                        <p:inputText id="body" value="#{messageController.selected.body}" title="#{bundle.EditMessageTitle_body}" />

                        <p:outputLabel value="#{bundle.EditMessageLabel_date}" for="date" />
                        <p:calendar id="date" pattern="MM/dd/yyyy HH:mm:ss" value="#{messageController.selected.date}" title="#{bundle.EditMessageTitle_date}"  showOn="button"/>

                        <p:outputLabel value="#{bundle.EditMessageLabel_userMessages}" for="userMessages" />
                        <p:selectOneMenu id="userMessages" value="#{messageController.selected.userMessages}" >
                            <f:selectItem itemLabel="#{bundle.SelectOneMessage}"/>
                            <f:selectItems value="#{userMessagesController.items}"
                                           var="userMessagesItem"
                                           itemValue="#{userMessagesItem}"
                                           itemLabel="#{userMessagesItem.messageIdmessage.toString()}"
                                           />
                            <f:converter binding="#{userMessagesConverter}"/>
                        </p:selectOneMenu>
                    </p:panelGrid>
                    <p:commandButton actionListener="#{messageController.save}" value="#{bundle.Save}" update="display,:MessageListForm:datalist,:growl" oncomplete="handleSubmit(xhr,status,args,MessageEditDialog);"/>
                    <p:commandButton value="#{bundle.Cancel}" onclick="MessageEditDialog.hide()"/>
                </h:panelGroup>

            </h:form>

        </p:dialog>

    </ui:composition>

</html>
